print('分段函数求值 ')
x = 10
if x > 1:
    y = 3 * x - 5
elif x >= -1:
    y = x + 2
else:
    y = 5 * x + 3
print('f(%.2f) = %.2f' % (x, y))
print('\n')

print('分段函数求值嵌套')
x = 1
if x > 1:
    y = 3 * x - 5
else:
    if x >= -1:
        y = x + 2
    else:
        y = 5 * x + 3
print('f(%.2f) = %.2f' % (x, y))
print('\n')

print('英制单位英寸喝公制单位厘米互换')
value = 50
unit = 'in'
if unit == 'in' or unit == '英寸':
    print('%f英寸 = %.2f厘米' % (value, value * 2.54))
elif unit == 'cm' or unit == '厘米':
    print('%f厘米 = %.2f英寸' % (value, value / 2.54))
else:
    print('请输入有效单位')
print('\n')

print('百分制成绩转换位等级制成绩')
score = 34
if score >= 90:
    grade = 'A'
elif score >= 80:
    grade = 'B'
elif score >= 70:
    grade = 'C'
elif score >= 60:
    grade = 'D'
else:
    grade = 'E'
print('你对应的等级是：', grade)
print('\n')

print('判断输入的边长能否构成三角形，如果能则计算出三角形的周长和面积')
a = 19
b = 53
c = 69
if a + b > c and a + c > b and b + c > a:
    p = a + b + c
    t = p / 2
    area = (t * (t - a) * (t - b) * (t - c)) ** 0.5
    print('周长：%d, 面积：%.2f' % (p, area))
else:
    print('不构成三角形')
print('\n')
